//	GuiDialog.cpp : All dialogs definition file.
//
#include <Windows.h>
#include "GuiDialog.h"

using namespace gKad;

#define	BUF_SIZE 1024

//
//	Source and file selection dialog.
//
BOOL CALLBACK DlgProc(HWND hwnd, UINT Message, WPARAM wParam, LPARAM lParam)
{
	// FIXME Naughty! Naughty!
	// http://msdn.microsoft.com/en-us/library/ms633521(v=vs.85).aspx
	// should do the trick	
	wchar_t		s[BUF_SIZE];
	struct dest_dlg_result *ret;		// to return
//	size_t		converted_chars;		// number of converted characters

	ret = (struct dest_dlg_result *) malloc( sizeof(struct dest_dlg_result));
	ret->file_name = (wchar_t *) malloc ( BUF_SIZE * sizeof(wchar_t) );

	switch(Message)
	{
	case WM_INITDIALOG:
		return true;
	case WM_COMMAND:
		switch(LOWORD(wParam))
		{
		case IDOK:		// user hit OK
			// get address
			s[GetDlgItemText(hwnd, 101,(LPWSTR) s, BUF_SIZE)] = '\0';
			CLSIDFromString(s, &ret->addr);

			// get file name
			s[GetDlgItemText(hwnd, 102,(LPWSTR) s, BUF_SIZE)] = '\0';
			memcpy(ret->file_name, s, BUF_SIZE);

			EndDialog(hwnd, (int) ret);
			break;
		}
		break;
	default:
		return false;
	}

	return false;
}
